﻿using King.Box.DbProvider.Migrations;
using King.Box.Utils;
using System.Data.Entity;
using System.Data.Entity.Migrations;
using System.Linq;

namespace King.Box.DbProvider.Impl
{
    public class DbInitProvider : IDbInitProvider
    {
        public void Init()
        {
            #if DEBUG
                        Database.SetInitializer<DalContextInitialize>(new ConfigurationDropDatabase());
            #else
                        Database.SetInitializer(new MigrateDatabaseToLatestVersion<DalContextInitialize, ConfigurationMigrationsDataBase>());   
            #endif

            SingletonBase<DalContextInitialize>.Initialize(new DalContextInitialize("ConnectionString"));
            SingletonBase<DalContextInitialize>.Instance.Database.Initialize(true);
        }
    }
}
